package com.ruoyi.web.controller.admin.faq;

import com.ruoyi.admin.domain.LlmFaqDownvoteDetail;
import com.ruoyi.admin.service.faq.LlmFaqDownvoteDetailService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping("/faq/downvote")
@RequiredArgsConstructor
public class LlmFaqDownvoteDetailController extends BaseController {

    private final LlmFaqDownvoteDetailService LlmFaqDDService;

    /**
     * 新增数据
     */
    @PostMapping("/addFaqDetail")
    public AjaxResult addFaqDetail(@RequestBody LlmFaqDownvoteDetail llmFaqDownvoteDetail) {
        return LlmFaqDDService.addFaqDetail(llmFaqDownvoteDetail) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 根据id删除数据
     */
    @DeleteMapping("/deleteFaqDetail")
    public AjaxResult deleteFaqDetail(@RequestParam("id") String FaqDownvoteId) {
        return LlmFaqDDService.deleteFaqDetail(FaqDownvoteId) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 修改数据
     */
    @PutMapping("/editFaqDetail")
    public AjaxResult editFaqDetail(@RequestBody LlmFaqDownvoteDetail llmFaqDownvoteDetail) {
        return LlmFaqDDService.editFaqDetail(llmFaqDownvoteDetail) ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 通过会话id 和用户id 查询会话里面的赞踩记录
     *
     * @param conversationId 会话id
     * @param userId         用户id
     * @return
     */

    @GetMapping("/getDownVoteByConversationId")
    public AjaxResult getDownVoteByConversationId(@RequestParam("conversationId") String conversationId, @RequestParam("userId") String userId) {
        return AjaxResult.success(LlmFaqDDService.getFaqDownvoteDtailByConversationId(conversationId, userId));
    }

    /**
     * 根据ID查询
     */
    @GetMapping("/{id}")
    public LlmFaqDownvoteDetail getFaqDetailById(@PathVariable String id) {
        return LlmFaqDDService.getFaqDetailById(id);
    }

    /**
     * 查询所有
     */
    @GetMapping("/list")
    public TableDataInfo listFaqDetailAll() {
        startPage();
        return getDataTable(LlmFaqDDService.list());
    }


}
